package data.stock;

import java.io.Serializable;

/**
 * The Ticker class contains historical information regarding a particular stock
 * @author Kevin Dolan
 */
public class Ticker implements Serializable {

	private static final long serialVersionUID = 4210252739177384719L;
	private String symbol;
	private String searchTerm;
	private NewsCorpus corpus;
	private DataHistory[] dataHistory;
	
	public Ticker(String symbol, String searchTerm, NewsCorpus corpus, DataHistory[] dataHistory) {
		this.symbol = symbol;
		this.searchTerm = searchTerm;
		this.corpus = corpus;
		this.dataHistory = dataHistory;
	}

	public String getSymbol() {
		return symbol;
	}

	public String getSearchTerm() {
		return searchTerm;
	}

	public NewsCorpus getCorpus() {
		return corpus;
	}

	public DataHistory getDataHistory(int which) {
		return dataHistory[which];
	}
	
	/**
	 * Get a subsection of the ticker
	 * @param start the starting time, inclusive
	 * @param end   the ending time, inclusive
	 * @return 		a ticker with only datapoints/news in the range
	 */
	public Ticker getSubTicker(long start, long end) {
		NewsCorpus subCorpus = corpus.getSubCorpus(start, end);
		DataHistory[] subData = new DataHistory[dataHistory.length];
		for(int i = 0; i < dataHistory.length; i++)
			subData[i] = dataHistory[i].getSubHistory(start, end);
		return new Ticker(symbol, searchTerm, subCorpus, subData);
	}
	
}